package com.xuanxing123.model;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import javax.persistence.*;
import static javax.persistence.GenerationType.IDENTITY;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;

@Entity
@Table(name="selection_contact_info",catalog="xuanxing")
@Searchable
@XmlRootElement
public class SelectionContactInfo extends BaseObject implements Serializable {
    private Long id;
    private Selection selection;
    private String companyName;
    private String companyAddress;
    private String companyZipcode;
    private String contactsName;
    private String contactsMail;
    private String contactsPhone;
    private Integer contactsRole;
    private Integer contactsJobTitle;

   @Id
//   @GeneratedValue(generator = "foreign")
//   @GenericGenerator(name = "foreign", strategy = "foreign",
//              parameters = { @Parameter(name = "property", value = "selection") })
     @GeneratedValue(strategy=IDENTITY)
    @SearchableId
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }

  @OneToOne(cascade = CascadeType.ALL , mappedBy="selectionContactInfo")
    public Selection getSelection() {
        return this.selection;
    }
    
    public void setSelection(Selection selection) {
        this.selection = selection;
    }
    
    @Column(name="company_name", length=100)
    @SearchableProperty
    public String getCompanyName() {
        return this.companyName;
    }
    
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    
    @Column(name="company_address", length=254)
    @SearchableProperty
    public String getCompanyAddress() {
        return this.companyAddress;
    }
    
    public void setCompanyAddress(String companyAddress) {
        this.companyAddress = companyAddress;
    }
    
    @Column(name="company_zipcode", length=10)
    @SearchableProperty
    public String getCompanyZipcode() {
        return this.companyZipcode;
    }
    
    public void setCompanyZipcode(String companyZipcode) {
        this.companyZipcode = companyZipcode;
    }
    
    @Column(name="contacts_name", length=20)
    @SearchableProperty
    public String getContactsName() {
        return this.contactsName;
    }
    
    public void setContactsName(String contactsName) {
        this.contactsName = contactsName;
    }
    
    @Column(name="contacts_mail", length=50)
    @SearchableProperty
    public String getContactsMail() {
        return this.contactsMail;
    }
    
    public void setContactsMail(String contactsMail) {
        this.contactsMail = contactsMail;
    }
    
    @Column(name="contacts_phone", length=20)
    @SearchableProperty
    public String getContactsPhone() {
        return this.contactsPhone;
    }
    
    public void setContactsPhone(String contactsPhone) {
        this.contactsPhone = contactsPhone;
    }
    
    @Column(name="contacts_role")
    @SearchableProperty
    public Integer getContactsRole() {
        return this.contactsRole;
    }
    
    public void setContactsRole(Integer contactsRole) {
        this.contactsRole = contactsRole;
    }
    
    @Column(name="contacts_job_title")
    @SearchableProperty
    public Integer getContactsJobTitle() {
        return this.contactsJobTitle;
    }
    
    public void setContactsJobTitle(Integer contactsJobTitle) {
        this.contactsJobTitle = contactsJobTitle;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SelectionContactInfo pojo = (SelectionContactInfo) o;

        if (selection != null ? !selection.equals(pojo.selection) : pojo.selection != null) return false;
        if (companyName != null ? !companyName.equals(pojo.companyName) : pojo.companyName != null) return false;
        if (companyAddress != null ? !companyAddress.equals(pojo.companyAddress) : pojo.companyAddress != null) return false;
        if (companyZipcode != null ? !companyZipcode.equals(pojo.companyZipcode) : pojo.companyZipcode != null) return false;
        if (contactsName != null ? !contactsName.equals(pojo.contactsName) : pojo.contactsName != null) return false;
        if (contactsMail != null ? !contactsMail.equals(pojo.contactsMail) : pojo.contactsMail != null) return false;
        if (contactsPhone != null ? !contactsPhone.equals(pojo.contactsPhone) : pojo.contactsPhone != null) return false;
        if (contactsRole != null ? !contactsRole.equals(pojo.contactsRole) : pojo.contactsRole != null) return false;
        if (contactsJobTitle != null ? !contactsJobTitle.equals(pojo.contactsJobTitle) : pojo.contactsJobTitle != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (selection != null ? selection.hashCode() : 0);
        result = 31 * result + (companyName != null ? companyName.hashCode() : 0);
        result = 31 * result + (companyAddress != null ? companyAddress.hashCode() : 0);
        result = 31 * result + (companyZipcode != null ? companyZipcode.hashCode() : 0);
        result = 31 * result + (contactsName != null ? contactsName.hashCode() : 0);
        result = 31 * result + (contactsMail != null ? contactsMail.hashCode() : 0);
        result = 31 * result + (contactsPhone != null ? contactsPhone.hashCode() : 0);
        result = 31 * result + (contactsRole != null ? contactsRole.hashCode() : 0);
        result = 31 * result + (contactsJobTitle != null ? contactsJobTitle.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("selection").append("='").append(getSelection()).append("', ");
        sb.append("companyName").append("='").append(getCompanyName()).append("', ");
        sb.append("companyAddress").append("='").append(getCompanyAddress()).append("', ");
        sb.append("companyZipcode").append("='").append(getCompanyZipcode()).append("', ");
        sb.append("contactsName").append("='").append(getContactsName()).append("', ");
        sb.append("contactsMail").append("='").append(getContactsMail()).append("', ");
        sb.append("contactsPhone").append("='").append(getContactsPhone()).append("', ");
        sb.append("contactsRole").append("='").append(getContactsRole()).append("', ");
        sb.append("contactsJobTitle").append("='").append(getContactsJobTitle()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
